package com.atguigu;

import java.util.Iterator;
import java.util.List;

/**
 * 信息学院接口实现类 IteratorImpl
 * @author melo
 */
public class InfoCollegeIterator implements Iterator<Department> {

    /**
     * 信息工程学院是以List方式存放院系
     */
    List<Department> departmentList;

    /**
     * 索引
     */
    int index = -1;

    public InfoCollegeIterator(List<Department> departmentList) {
        this.departmentList = departmentList;
    }

    /**
     * 判断list中还有没有下一个元素
     *
     * @return 判断结果
     */
    @Override
    public boolean hasNext() {
        if (index >= departmentList.size() - 1) {
            return false;
        } else {
            index ++;
            return true;
        }
    }

    @Override
    public Department next() {
        return departmentList.get(index);
    }

    /**
     * 空实现remove
     */
    @Override
    public void remove() {

    }

}
